package com.guigu.controller.manufacture;


import com.guigu.pojo.manufacture.MProcedure;
import com.guigu.service.manufacture.MProcedureService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Mr.Zhang
 * @since 2024-12-06
 */
@Controller
@RequestMapping("/m-procedure")
public class MProcedureController {

    @Autowired
    private MProcedureService mProcedureService;

    @GetMapping("/selectArrByParentId")
    @ResponseBody
    public ArrayList<MProcedure> selectArrByParentId(HttpServletRequest req){
        Integer id = StringUtils.isNotBlank(req.getParameter("id")) ? Integer.parseInt(req.getParameter("id")) : null;
        ArrayList<MProcedure> mProcedures = mProcedureService.selectArrByParentId(id);
        return mProcedures;
    }

    @GetMapping("/selectOneById")
    @ResponseBody
    public MProcedure selectOneById(HttpServletRequest req){
        Integer id = StringUtils.isNotBlank(req.getParameter("id"))? Integer.parseInt(req.getParameter("id")) : null;
        MProcedure mProcedure = mProcedureService.getById(id);
        return mProcedure;
    }

}

